Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: API 34 Support #1678

Merged
merged 18 commits into from
May 13, 2024
Merged

feat!: API 34 Support #1678

merged 18 commits into from
May 13, 2024

Conversation

breautek
Copy link
Contributor

@breautek breautek commented Oct 21, 2023

Platforms affected

Android

Motivation and Context

Adds in support for the next android platform

Closes #1661
Closes #1596

Description

This PR supercedes and includes #1596

This PR does a few different things to provide API 34 support which will be noted below.

Breaking Changes

These are notable changes that is breaking that may affect plugins or workflows. It doesn't highlight all breaking changes in which were hidden inside implementation details.

  • JDK 17 is now required
  • Cordova-Android will now use Gradle 8.7 by default
  • Android Studio Jellyfish. Android Studio is not required for building via the Cordova CLI.

Default Configuration Changes

Target SDK: 34
Gradle Version: 8.7
AGP Version: 8.3.0
Kotlin JVM Target: 1.8 (If kotlin is enabled)
Min Build Tools: 34

Java/Kotlin Changes

Source/Target compatibility we changed from Java 8 to 17 on both the framework and app template projects.

Source & Target compatibility have been reverted back to 8, but 2 new preferences are added to allow developers to experiment: AndroidJavaSourceCompatibility and AndroidJavaTargetCompatibility which adjusts the respective gradle compile options. By default, these values are 8, which is the same values used before.

Additionally, AndroidKotlinJVMTarget preference was added to select the Kotlin JVM target. By default, the Kotlin JVM Target will be same as AndroidJavaTargetCompatibility. Updating AndroidJavaTargetCompatibility will influence the Kotlin JVM target unless if AndroidKotlinJVMTarget is also explicitly defined.

BuildConfig

Previously this I believe was implicitly enabled, but now needs to be explictly enabled otherwise the following may occur

* What went wrong:
A problem occurred configuring project ':app'.
> com.android.builder.errors.EvalIssueException: defaultConfig contains custom BuildConfig fields, but the feature is disabled.
  To enable the feature, add the following to your module-level build.gradle:
  `android.buildFeatures.buildConfig true`

I however did not encounter this on a simple project, so it might be required depending on what the plugins does.

AGP 8.3

AGP 8.2 is the minimum version required for API 34 builds. Attempting build against API 34 on earlier versions will produce warnings and/or errors.

AGP 8.3 is however the latest version that can be used with standard Android Studio configurations.

AGP 8.4 was tested with and will mostly work, but will not work inside Android Studio without further configuration. Because we don't want to impose Android Studio configurations onto the user, AGP 8.3 is chosen for cordova-android@13 release.

Gradle -b flag

This flag has been deprecated and scheduled to be removed in gradle's next major release.
The gradle projects must follow a standard structure now. Cordova's generated project already follows the standard structure thus for cordova build commands the -b append can simply just be removed, we don't need to explicitly declare the build.gradle file.

It was also used against the wrapper.gradle file which changes are noted below.

gradle.wrapper

The "intentionally empty" gradle.wrapper file has been removed.

We no longer manually manage gradle versions. Instead, we let gradle do it for us by utilising their --gradle-version argument. A new function was introduced to replace the old runGradleWrapper to:

  1. setup the gradle wrapper if not already present
  2. install/update the gradle wrapper to the specified version.

By default, this will be 8.7 as defined in the defaults json config file, but may be overwritten by GradleVersion preference, or CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL environment variable.

If CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL is defined, the preference will be ignored and --distribution-url will be used instead, maintaining the ability for corporations to install their own gradle wrapper from their own source.

The Gradle Wrapper was previously checked into the repo and was removed. It has since returned as using the system gradle to generate the wrapper caused issues. Namely it would require end-users to have an appropriate gradle version that satisfies AGP, which kind of defeats the purpose of using wrappers.

Because -b flag will be going away, there is now a tools project that is templated and copies. This project serves as the old wrapper.gradle, in that it's an empty project that can be used by the system gradle of a varying version range to produce the gradle wrapper at the version that we need to build the android project.

~obsolete gradle-wrapper notes~

This section is no longer in the PR

While personally I do not agree with how Gradle handles this, it is their recommendation to check in the Gradle wrapper, including the jar file into the source.

To make the Wrapper files available to other developers and execution environments, you need to check them into version control. Wrapper files, including the JAR file, are small. Adding the JAR file to version control is expected. Some organizations do not allow projects to submit binary files to version control, and there is no workaround available.

As usual, you should commit the changes to the Wrapper files to version control.

This done for both our test project and the app template. On platform add, the wrapper will be copied from the template. Individual projects via GradleVersion may change the wrapper version.

Should the end user choose a gradle version below what was required by AGP, gradle will update the gradle version, but builds will fail. Attempting to update the version back to an acceptable version will cause the gradle wrapper task to fail as the wrapper task also loads in AGP. To avoid this, Cordova does a version check before executing the wrapper task and will not update the wrapper if it's below the minimum required.

Note that while by preference both Gradle Version and AGP versions are configurable, the version check is not. This means that even if you drop Gradle and AGP down a version, the current >= 8.6 check will remain. I think this is OK since these preferences are documented for internal development use.

Lastly, because of the introduction of using --gradle-version and letting gradle manage our wrappers, the clean gradle wrapper script we had for our test project became obsolete and was removed.

Android Studio

With AGP 8.3, Android Studio Jellyfish will now be required for opening the native project.

CI

JDK was updated from 11 to 17, which is a requirement to build for API 34

Testing

Ran NPM test
Ran in sample cordova hello world app, with variety of different configurations
Ran in one of my projects

Known Issues

  • The core splashscreen plugin does not compile when targeting JDK 17.

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@breautek breautek added this to the 13.x milestone Oct 21, 2023
@codecov-commenter
Copy link

codecov-commenter commented Oct 21, 2023

Codecov Report

Attention: Patch coverage is 86.36364% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 72.50%. Comparing base (ed8e5d2) to head (b974bba).

Files Patch % Lines
lib/builders/ProjectBuilder.js 80.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1678      +/-   ##
==========================================
+ Coverage   72.15%   72.50%   +0.35%     
==========================================
  Files          23       23              
  Lines        1839     1837       -2     
==========================================
+ Hits         1327     1332       +5     
+ Misses        512      505       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

framework/build.gradle Outdated Show resolved Hide resolved
EiyuuZack added a commit to OutSystems/cordova-android that referenced this pull request Nov 29, 2023
From upstream (apache#1678):

Gradle -b flag

This flag has been deprecated and scheduled to be removed
in gradle's next major release. The gradle projects must follow a
standard structure now. Cordova's generated project already follows the
standard structure thus for cordova build commands the -b append can
simply just be removed, we don't need to explicitly declare the
build.gradle file.

It was also used against the wrapper.gradle file which changes are noted
below.

gradle.wrapper

The "intentionally empty" gradle.wrapper file has been removed.

We no longer manually manage gradle versions. Instead, we let gradle do
it for us by utilising their --gradle-version argument. A new function
was introduced to replace the old runGradleWrapper to:

setup the gradle wrapper if not already present install/update the
gradle wrapper to the specified version. By default, this will be 8.4
as defined in the defaults json config file, but may be overwritten by
GradleVersion preference, or CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL
environment variable.

If CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL is defined, the preference
will be ignored and --distribution-url will be used instead, maintaining
the ability for corporations to install their own gradle wrapper from
their own source.

References https://outsystemsrd.atlassian.net/browse/RNMT-6402
EiyuuZack added a commit to OutSystems/cordova-android that referenced this pull request Nov 29, 2023
From upstream (apache#1678):

Gradle -b flag

This flag has been deprecated and scheduled to be removed
in gradle's next major release. The gradle projects must follow a
standard structure now. Cordova's generated project already follows the
standard structure thus for cordova build commands the -b append can
simply just be removed, we don't need to explicitly declare the
build.gradle file.

It was also used against the wrapper.gradle file which changes are noted
below.

gradle.wrapper

The "intentionally empty" gradle.wrapper file has been removed.

We no longer manually manage gradle versions. Instead, we let gradle do
it for us by utilising their --gradle-version argument. A new function
was introduced to replace the old runGradleWrapper to:

 1. setup the gradle wrapper if not already present
 2. install/update the gradle wrapper to the specified version

By default, this will be 8.4 as defined in the defaults json config
file, but may be overwritten by GradleVersion preference, or
CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL environment variable.

If CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL is defined, the preference
will be ignored and --distribution-url will be used instead, maintaining
the ability for corporations to install their own gradle wrapper from
their own source.

References https://outsystemsrd.atlassian.net/browse/RNMT-6402
@breautek breautek force-pushed the api34-support branch 2 times, most recently from b756804 to 24b72b5 Compare December 1, 2023 18:12
EiyuuZack added a commit to OutSystems/cordova-android that referenced this pull request Dec 4, 2023
The mapping is pretty straightforward:

AndroidJavaSourceCompatibility > Java Source Files - defaults to (Java) 8
AndroidJavaTargetCompatibility > Java Compiler - defaults to (Java 8
AndroidKotlinJvmTarget > Kotlin Compiler - defaults to '1.8'

AndroidJavaTargetCompatibility and AndroidKotlinJvmTarget should target
the same semantic Java version to avoid build conflicts due to different
JDKs. Only sane defaults are provided, no further checks are performed.

See apache#1678 for more info.

References https://outsystemsrd.atlassian.net/browse/RNMT-6402
@breautek breautek mentioned this pull request Dec 19, 2023
@breautek breautek force-pushed the api34-support branch 2 times, most recently from de2f1f3 to 0a1f947 Compare January 14, 2024 01:35
@breautek breautek marked this pull request as ready for review January 14, 2024 01:46
@erisu erisu modified the milestones: 13.x, 13.0.0 May 7, 2024
framework/cdv-gradle-config-defaults.json Outdated Show resolved Hide resolved
lib/prepare.js Show resolved Hide resolved
@breautek
Copy link
Contributor Author

I consider it a 'hard requirement' for users to upgrade to Android Studio Jellyfish at a minimum for successful builds and seamless functionality from Android Studio, as the term 'recommended' suggests that the version is not mandatory.

Older versions of Android Studio are not compatible with AGP 8.4 and will fail.

I've updated the wording, also added a smaller Breaking Changes section that highlights in short bullet-form of the notable breaking changes.

jcesarmobile and others added 16 commits May 13, 2024 07:17
API 34: Upgrade AGP from 8.2.0-rc01 to 8.2.0-rc02

API 34: Upgrade AGP from 8.2.0-rc02 to 8.2.0-rc03

API 34: Upgrade AGP from 8.2.0-rc03 to 8.2.0

feat: add AndroidKotlinJVMTarget preference to set the kotlin JVM target
This is in addition to the java source / target compatibility preferences.
AndroidKotlinJVMTarget is only affective if Kotlin is enabled.

chore: Upgrade Gradle from 8.4 to 8.5

AGP 8.2.0 -> 8.2.1

Gradle 8.5 -> 8.7

fix: Add --validate-url to gradle wrapper commands

AGP 8.4.0
The new default value is null. When null, it will by default
to the Java Target compatibility. Updating AndroidJavaTargetCompatibility
will also influence the Kotlin JVM target, unless if AndroidKotlinJVMTarget
is also explicitly defined.
@breautek
Copy link
Contributor Author

I've reverted AGP down to 8.3

Jellyfish appears to bundle Gradle 8.4 by default and will fail on installing the wrapper due to AGP 8.4's requirement on Gradle 8.6. In order to use AGP 8.4 on Jellyfish, the user would have to do additional configurations to specify an alternate gradle.

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@breautek breautek requested a review from erisu May 13, 2024 12:51
Copy link
Member

@erisu erisu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM

I have tested the following:

  • cordova platform add
  • cordova build android
  • Android Studio Jellyfish
    • Gradle Sync
    • Build and Run on Emulator

I confirmed that Gradle 8.7 and AGP 8.3 is used.

@breautek breautek merged commit 89a0a72 into apache:master May 13, 2024
14 checks passed
@breautek breautek deleted the api34-support branch May 13, 2024 13:29
graphefruit added a commit to graphefruit/Beanconqueror that referenced this pull request May 25, 2024
…eded). apache/cordova-android#1678

Added kotlin version etc.

Removing splash files, after they are not longer supported with android
graphefruit added a commit to graphefruit/Beanconqueror that referenced this pull request Jun 28, 2024
* #704, #705 Add third wave water profiles, and make water section like the preparation methods, to add a specific or custom one.

* We removed in lokalise all old translations to make some more cleanup.

* Preset third wave water translations

* Changed font size

* Resetting smoothedValue when attaching to the scale flow

* #709, #708, #707, #706

Added haptic engine
added text to speech for bluetooth scale connection
added sort of images
added indicator that machines are connected

* #710 - toggle hour and minutes

* #711 - Enable tare again on brew timer start when pressure or temperature threshold is hit cause of logic changes

* #712 - Unarchive a bean

* #713 - Focus seconds directly when opening the timer

* #714 - Save again the brew when the while brewing is shown

* #715 - Send EY to visualizer

* Adding Bookoo devices

* Adding translations

* Corrected identifier name, testDeviceScan corrected, aswell as searching the pressure devices to find the bookoo pressure

* Swiching to nativestorage back

* Removing splash screens

* Removing splash screen plugin, upgrading to android 13 (jdk 17 now needed). apache/cordova-android#1678

Added kotlin version etc.

Removing splash files, after they are not longer supported with android

* Making text to speech just for IOS possible, aswell as fixing android image choosing with new version update

* update text

* Removed unused function

* Made extraction chart labels translatable (#718)

Co-authored-by: Lars Saalbach <lars.saalbach@googlemail.com>

* Fix typos in Spanish translation (#716)

* update text

* Added first 7.3.0 update texts

* outcomenting the bookoo pressure

* Add new functions for starting Value Transmission

* Use Value Transmission functions depending on timer

* Commiting the pressure changes for the booko

* Fixing the meticulous API data :)

* Adding the strip android permissions, specialy for write storage aswell for:
android.permission.BODY_SENSORS

android.permission.ACTIVITY_RECOGNITION

* Fix pin formater for beans

* Set final weight for meticulous

* Updating 7.3 patchnotes

* Fixing to the next version

* Fixing iOS image selection

* #721 - Adding download button for brew by weight & retrying the call to the xenia.

* #721 - Fixing null value

* Lokalise update (#724)

* Fixings the MA_STATUS Wait, and wait 2 seconds.
Changing the notes and aromatics to the bottomline

* Lokalise update (#725)

* Lokalise update (#727)

* Enabling pressure sensor, updating to 7.3.0 version tag

* Fix tests after master merge.

* Everywhere: Add missing decalations, imports and providers.
* water-information-card: Add a water.type so Water.getIcon returns.
* app.component: Remove Platform spy because it was missing is function

* #736 - Removing the plugin cause of the core dependency

* Add missing OnDestroy to BrewAddComponent. (#738)

Original fix in b9ffb35 by AdrisGithub.
ngOnDestroy added in 5538f04.

* Remove duplicate text in README.md (#729)

Duplicate text aded in 9d05b7c

Co-authored-by: Grapehfruit <lars.saalbach@googlemail.com>

* Split beforEach calls into async and sync calls.

compileComponents is async so it needs to be in a waitForAsync block. The actual component creation should be in a sync block.
Reference: https://angular.dev/guide/testing/components-scenarios#calling-compilecomponents

* Delete unused import.

setParseTemplateAsSourceFileForTest

* Uncomment CuppingRadarComponent test.

Register chart.js components in the same way as is done in app.component.ts

* Revert changes to plotly.min.js.

This file is imported, it shouldn't have been re-formatted.

* Fix and uncomment graph-display-card.component.spec.ts.

Split beforEach in async and sync.
Clean up formatting.

* UnComment and fix BrewBrewingGraphComponent test.

* Create a MockBrew class that extends Brew and stubs out reading the Preparation from storage.
* Provide MockBrew instance as `data` input.
* In BrewBrewingGraphComponent.getPreparation, delegate to this.data.getPreparation insteda of re-implementing reading from storage. This allows for stubbing the storage read in a single palce.
* Split beforeEach in async and sync sections ref: https://angular.dev/guide/testing/components-scenarios#calling-compilecomponents

---------

Co-authored-by: Grapehfruit <lars.saalbach@googlemail.com>
Co-authored-by: randomcoffeesnob <ydietler@gmail.com>
Co-authored-by: agubelu <agubelu@users.noreply.github.com>
@ramona-cristea
Copy link

Hello,

Does Cordova support Android 14? I saw you were working on it (api34-support), but didn't see any update on the oficial documentation here https://cordova.apache.org/docs/en/12.x/guide/platforms/android/index.html ?
Is there a version 13.0.0 of Cordova which targets Android 14? Thank you!

@breautek
Copy link
Contributor Author

breautek commented Jul 4, 2024

Is there a version 13.0.0 of Cordova which targets Android 14? Thank you!

Yes. See here for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support AGP 8.1+ by using JVM 17
8 participants